package com.minimalist.common.config.mybatis.bo;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;

/**
 * 分页响应对象
 *
 * @param <T> 数据类型
 * @author 11987
 */
public class PageResp<T> implements Serializable{

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 数据列表
     */
    private List<T> records;

    /**
     * 总记录数
     */
    private long total;

    public PageResp() {
    }

    public PageResp(List<T> records, long total) {
        this.records = records;
        this.total = total;
    }

    public List<T> getRecords() {
        return records;
    }

    public void setRecords(List<T> records) {
        this.records = records;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PageResp<?> pageResp = (PageResp<?>) o;
        return total == pageResp.total && Objects.equals(records, pageResp.records);
    }

    @Override
    public int hashCode() {
        return Objects.hash(records, total);
    }

    @Override
    public String toString() {
        return "PageResp{" +
                "records=" + records +
                ", total=" + total +
                '}';
    }
}
